<template>
	<view class="fee">
		<view class="">
			<!-- 2.0.19支持autoBack，默认为false -->
			<u-navbar leftText="我的房屋" :autoBack="true">
			</u-navbar>
		</view>
		<view class="con-body" style=" background-color: #F2F3F5;">
			<u-radio-group v-model="defaultHouse" placement="column" @change="groupChange">
				<view class="uni-flex-center" v-for="(item, index) in houseList">


					<view class="main-service uni-cell-90" style="padding-bottom: 10rpx; width: 96%; margin-left: 2%;">
						<view class="user-list">
							<view class="" style="font-weight: bold;">
								<u-cell-group :border="false">
									<u-cell icon="https://resourse.cnlhjt.com/upload/20220825/651206a7d0688d69f6448bb5c016854c.png" :title="item.house"
										:border="false"></u-cell>
								</u-cell-group>

							</view>
							<u-line></u-line>
							<view style="padding-left: 20rpx; padding-right: 20rpx; padding-bottom: 20rpx;">
								<view class="d_view">
									<text class="l_title">业主：</text>
									<text class="d_content">{{item.name}}</text>
								</view>

								<view class="d_view">
									<text class="l_title">入住时间：</text>
									<text class="d_content">{{item.time}}</text>
								</view>
							</view>
							<u-line></u-line>
							<u-radio :customStyle="{margin: '8px', float: 'right'}" :key="index" label="设为当前房屋"
								:name="item.id" activeColor="#008987" @change="radioChange">
							</u-radio>
							<view style="clear: both;"></view>
						</view>
					</view>
				</view>
			</u-radio-group>
		</view>
		<view style="height: 140rpx;"></view>
		<u-empty :show="showEmpty" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
		</u-empty>
		<u-button :customStyle="btnStyle" @click="intoBind">绑定房屋</u-button>
	</view>
</template>

<script>
	import {
		getHouse,
		defaultHouse
	} from "@/service/userService.js";
	export default {
		data() {
			return {
				btnStyle: {
					width: '96%',
					borderRadius: '40rpx',
					marginLeft: '2%',
					backgroundImage: "url('https://resourse.cnlhjt.com/upload/20220825/d1aa35c1d129137d9b12c8f34e59c5bc.png')",
					backgroundSize: '100% 80rpx',
					color: '#FFFFFF',
					position: 'fixed',
					bottom: '40rpx'
				},
				defaultHouse: '1',
				houseList: [],
				showEmpty: false
			}
		},
		onLoad() {
			getHouse().then(this.getHouse)
		},
		methods: {
			groupChange(n) {
				defaultHouse({
					hid: this.defaultHouse
				}).then(res => {
					// console.log(res);
				})
			},
			radioChange(n) {
				// console.log('radioChange', n);
			},
			intoBind() {
				this.$u.route({
					url: "/pagesMine/house/bind",
					params: {

					}
				})
			},
			getHouse(e) {
				if (e.code == 200) {
					this.defaultHouse = e.result.default;
					this.showEmpty = false;
					this.houseList = e.result.data;
				} else {
					this.showEmpty = true;
				}
			}
		}
	}
</script>

<style lang="scss">
	.l_title {
		font-size: 32rpx;
		color: #999999;
	}

	.d_content {
		color: #666666;
		font-size: 32rpx;
	}

	.d_view {
		margin-top: 30rpx;
	}
</style>
